package com.baic.ibase.models.req.common;

import com.baic.ibase.models.dao.Users;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;


@AllArgsConstructor
@NoArgsConstructor
@Data
public class ApiResponse<T> implements Serializable {

    private int code;

    private String message;

    private String errors;

    private String traceId;

    private boolean success;

    private T data;

    public static <T> ApiResponse<T>  ok() {
        return new ApiResponse<T>(200, "success", null, null, true, null);
    }

    public static <T> ApiResponse<T>  ok(T data) {
        return new ApiResponse<T>(200, "success", null, null, true, data);
    }

    public static <T> ApiResponse<T>  ok(String message, T data) {
        return new ApiResponse<T>(200, message, null, null, true, data);
    }

    public static <T> ApiResponse<T>  ok(String message, String traceId, T data, int code) {
        return new ApiResponse<T>(code, message, null, traceId, true, data);
    }

    public static <T> ApiResponse<T>  error(int code, String message) {
        return new ApiResponse<T>(code, message, null, null, false, null);
    }

    public static <T> ApiResponse<T>  error(int code, String message, String errors) {
        return new ApiResponse<T>(code, message, errors, null, false, null);
    }

    public static <T> ApiResponse<T>  error(int code, String message, String errors, String traceId) {
        return new ApiResponse<T>(code, message, errors, traceId, false, null);
    }


}
